<template>
  <view class="page">
    <view class="content">
      <view class="word">{{ schoolData.name }}</view>
      <view class="mean"
        >{{ schoolData.area }}
        <text class="ml-20">{{ schoolData.competentDepartmentName }} </text>
        <text class="ml-20">{{ map1[schoolData.schoolNature] || "" }} </text>
      </view>
      <view class="flex flex-wrap">
        <text
          class="word-item"
          v-for="(item, index) in schoolData.schoolLevelNames"
          :key="index"
          >{{ item }}
        </text>
      </view>
    </view>

    <view class="content">
      <view class="tab-item mb-10">{{ `招生简章` }}</view>
      <view
        class="guide-item text-22"
        v-for="(item, index) in qryBrochList"
        :key="index"
        @click="toschoolGuide(item)"
        >{{ `[${item.year}]${item.name || ""}` }}
      </view>
    </view>

    <view class="content">
      <view class="tab-item mb-10">{{ `专业目录` }}</view>
      <view
        class="guide-item text-24"
        v-for="(item, index) in qrySpecList"
        :key="index"
        @click="toStart(item)"
        >{{ item.name }}
      </view>
    </view>

    <view class="content">
      <view class="tab-item mb-10"
        >{{ `招生计划` }}
        <picker @change="yearChange" :value="yearIndex" :range="yearArray">
          <view class="tab-year">{{ year }}</view>
        </picker>
      </view>
      <view class="table-one">
        <uni-table border stripe emptyText="暂无更多数据">
          <uni-tr>
            <uni-th width="100rpx" align="center">招生专业</uni-th>
            <uni-th width="110rpx" align="center">招生人数</uni-th>
            <uni-th width="140rpx" align="center">考试科目</uni-th>
            <uni-th width="110rpx" align="center">学费标准</uni-th>
          </uni-tr>
          <template v-for="(item, index) in qryAdmissionList" :key="index">
            <uni-tr>
              <uni-td align="center">{{ item.targetSpecialtyName }}</uni-td>
              <uni-td align="center">{{ item.planNum }}</uni-td>
              <uni-td align="center">
                <!-- {{
                item.subjectNames?.toString()
								
              }} -->
                <view
                  v-for="(item, index) in item.subjectNames"
                  :key="index"
                  >{{ item }}</view
                >
              </uni-td>
              <uni-td align="center">{{ item.tuition }}</uni-td>
            </uni-tr>
          </template>
        </uni-table>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      navList: [],
      qryBrochList: [],
      qrySpecList: [],
      qryAdmissionList: [],
      curNav: 0,
      schoolCode: "",
      schoolData: {},
      map1: {
        1: "公办",
        2: "民办（独立学院）",
        3: "民办",
        4: "中外合作办学机构",
        5: "中外（含内地与港澳台）",
        6: "合作院校",
      },
      size: 10,
      current: 1,
      total: 10,
      year: "",
      yearArray: [],
      yearIndex: 0,
    };
  },
  async onLoad(options) {
    this.schoolCode = options.schoolCode || "4143010536";
    this.getList();
    this.qryBrochuresList();
    this.qrySpecialtysList();
    await this.getqryYearList();
    this.getqryAdmissionPlanList();
  },
  onShow() {},
  onReachBottom() {},
  methods: {
    changeNav(i) {
      this.curNav = i;
    },
    yearChange(e) {
      if (e.detail.value == this.yearIndex) return;
      // console.log("yearChange=", e);
      this.yearIndex = e.detail.value;
      this.year = this.yearArray[this.yearIndex];
      this.getqryAdmissionPlanList();
    },
    toStart(item) {
      getApp().globalData.schoolCode = this.schoolCode;
      getApp().globalData.schoolName = this.schoolData.name;
      uni.navigateTo({
        url:
          "/pages/special/schoolSpecial" +
          "?schoolCode=" +
          this.schoolCode +
          "&specialtyId=" +
          item.id,
      });
    },
    toschoolGuide(item) {
      var content = item.content;
      // var content = "<p><strong>第一章 &nbsp;总 &nbsp;则</strong></p>";
      // var content =
      //   '<p style="text-align: center;"><strong style="text-indent: 43px; text-align: justify;">第一章 &nbsp;总 &nbsp;则</strong></p>';
      // content = content.replace(/style=\".+?\"/g, "");
      // console.log("content=", content);

      uni.navigateTo({
        url: "/pages/special/schoolGuide" + "?content=" + encodeURIComponent(content),
      });
    },

    getList() {
      this.$http
        .get1("/client/undergraduate/schoolDetail", {
          schoolCode: this.schoolCode,
          examType: 12,
        })
        .then((res) => {
          if (res.code == 200) {
            this.schoolData = res.data;
          }
        });
    },
    // 获取专升本学校招生简章
    qryBrochuresList() {
      this.$http
        .get1("/client/undergraduate/qryBrochures", {
          schoolCode: this.schoolCode,
          examType: 12,
        })
        .then((res) => {
          // console.log(res);
          if (res.code == 200) {
            this.qryBrochList = res.data;
          }
        });
    },
    // 获取专升本学校专业列表
    qrySpecialtysList() {
      this.$http
        .get1("/client/undergraduate/qrySpecialtys", {
          schoolCode: this.schoolCode,
          examType: 12,
        })
        .then((res) => {
          if (res.code == 200) {
            this.qrySpecList = res.data;
          }
        });
    },

    // 获取专升本学校招生计划列表
    getqryAdmissionPlanList() {
      this.$http
        .get1("/client/undergraduate/qryAdmissionPlan", {
          schoolCode: this.schoolCode,
          specialtyIds: "",
          year: this.year,
          examType: 12,
        })
        .then((res) => {
          if (res.code == 200) {
            this.qryAdmissionList = res.data;
          }
        });
    },

    getqryYearList(name = "") {
      return new Promise((resolve, reject) => {
        this.$http
          .get1("/client/undergraduate/qryYear", {
            examType: 12,
          })
          .then((res) => {
            if (res.code == 200) {
              this.yearArray = res.data;
              // this.yearArray.push(2023);
              this.year = res.data[this.yearIndex] || "";
              resolve();
            }
          });
      });
    },
  },
};
</script>

<style lang="scss">
page {
  background-color: #f2f3f8;
}
.page {
  padding: 50rpx 30rpx 200rpx;
  box-sizing: border-box;
}

.content {
  width: 100%;
  min-height: 120rpx;
  background: #ffffff;
  box-shadow: 0rpx 4rpx 8rpx 2rpx rgba(42, 65, 152, 0.05);
  border-radius: 20rpx;
  margin-bottom: 20rpx;
  padding: 30rpx 30rpx;
  box-sizing: border-box;
  .word {
    font-size: 30rpx;
    font-weight: bold;
    color: #333333;
  }
  .word-item {
    background-color: #5480f8;
    border-radius: 10rpx;
    margin-right: 12rpx;
    font-size: 24rpx;
    font-weight: 400;
    padding: 4rpx 10rpx;
    margin-top: 10rpx;
  }
  .mean {
    margin-left: 0rpx;

    font-size: 24rpx;
    color: #575a64;
  }

  .tab-item {
    // background-color: #5480f8;
    // border-radius: 10rpx;
    position: relative;
    font-size: 28rpx;
    font-weight: 400;
    padding: 2rpx 20rpx;
    // color: #ffffff;
    border-left: 8rpx solid #5480f8;
    .tab-year {
      position: absolute;
      right: 10rpx;
      top: 5rpx;
			font-size: 26rpx;
    }
  }
  .guide-item {
    padding: 4rpx 2rpx;
  }
  .table-one {
    font-size: 24rpx;

  }
	::v-deep .uni-table-th {
	  font-size: 22rpx;
	}
	::v-deep .uni-table-td {
	  font-size: 22rpx;
	}
}
.page-btn {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 176rpx;
  padding: 30rpx 62rpx;
  box-sizing: border-box;
  background-color: #fff;
  z-index: 10;
  .btn {
    width: 100%;
    height: 90rpx;
    background: #5480f8;
    border-radius: 46rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32rpx;
    font-weight: 500;
    color: #ffffff;
    &.disable {
      background-color: #cad8fc;
    }
  }
}

::v-deep(.uni-table-td) {
  font-size: 22rpx;
}
</style>
